//
//  WeekView.m
//  XTeng
//
//  Created by 周成龙 on 16/8/16.
//  Copyright © 2016年 ZCL. All rights reserved.
//

#import "WeekView.h"

#import "VDJConstant.h"

@implementation WeekView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self == [super initWithFrame:frame]) {
        
        CGFloat viewWidth = self.frame.size.width;
        CGFloat viewHeight = self.frame.size.height;
        
        NSArray *titls = @[@"星期一", @"星期二", @"星期三", @"星期四", @"星期五", @"星期六", @"星期日"];
        CGFloat btnWodth = viewWidth/7.0;
        for (int i = 0; i < 7; i ++) {
            UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
            btn.frame = CGRectMake(btnWodth*i, 0, btnWodth, viewHeight);
            btn.backgroundColor = kGrayFontColor;
            btn.tag = i;
            btn.titleLabel.font = kFontWithSize(12);
            [btn setTitle:titls[i] forState:UIControlStateNormal];
            [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
            [self addSubview:btn];
        }
    }
    return self;
}

- (void)btnClick:(UIButton *)sender
{
    if ([self.delegate respondsToSelector:@selector(didWeekItem:)]) {
        [self.delegate didWeekItem:sender];
    }
}

@end
